package net.entelijan.cobean.examples.showcase.config.filesel;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;

import net.entelijan.config.CobeanConfigFactory;
import net.entelijan.config.ICobeanConfig;
import net.entelijan.scf.IShowcase;

public class ConfigFileselShowcase implements
		IShowcase<ConfigFileselPanel> {

	private ConfigFileSelModel model = new ConfigFileSelModel();
	
	public ConfigFileselShowcase() {
		super();
	}

	@Override
	public void init(final ConfigFileselPanel view) {

		// Bind the view to the model using convetion over configuration.
		ICobeanConfig cfg = CobeanConfigFactory.createConfig();
		model = cfg.bind(model, view, null);

		view.getShowModelButton().addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(view, "" + model);
			}

		});

		view.getSetHomeButton().addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				System.out.println("TODO");
			}

		});

	}

	public ConfigFileSelModel getModel() {
		return model;
	}

	public void setModel(ConfigFileSelModel model) {
		this.model = model;
	}


}
